package com.ag.admin.web.tags;

import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import com.ag.common.EventUtil;
import com.ag.work2.service.IReportTagService;
import com.ag.zhh.service.EventStatusService;

/**
 * 假设事件正在处理中，则按钮不显示
 * 
 * @author Administrator
 * 
 */
public class ThirdReportTag extends TagSupport implements
		ApplicationContextAware {
	private static final long serialVersionUID = 6028892088476304107L;

	private static ApplicationContext context;// 声明一个静态变量保存

	private IReportTagService reportTagService;

	@Override
	public int doStartTag() throws JspException {
		reportTagService = (IReportTagService) context
				.getBean("LZMReportTagServiceImpl");
		HttpSession session = pageContext.getSession();
		int es = Integer.valueOf(reportTagService
				.findCurrentEventStatus((String) session
						.getAttribute(EventUtil.PROCESSING_EVENT_ID)));
		if (es < Integer.valueOf(EventStatusService.EVENT_STATUS_SJCHP_ING)) {
			return EVAL_BODY_INCLUDE;
		}
		return SKIP_BODY;
	}

	@Override
	public void setApplicationContext(ApplicationContext contex)
			throws BeansException {
		this.context = contex;
	}

	public static ApplicationContext getContext() {
		return context;
	}
}
